import { NavBar } from "antd-mobile";
import React, { useReducer, useEffect,useState } from "react";
import { reqGetbanner } from "../../http/api";
import Banner from "./Banner/Banner"
import { initState, reducer, actions } from "../Login/user";
import "./Mine.less"
// import user from "../../assets/img/user.png"
export default function Mine(props) {
    const [state, dispatch] = useReducer(reducer, initState)
    // 初始化数据
    const [getbanner, setgetbanner] = useState([])
    useEffect(()=>{
        reqGetbanner().then(res=>{
            if(res.data.code===200){
                setgetbanner(res.data.list)
            }
        })
    },[])
    return (
        <div className="home">
            <NavBar>我的</NavBar>

            <div className="nick">
               {/* <img src={user} alt="" /> */}
               <p> 昵称：{state.info.nickname}</p>
               </div>
            <span onClick={() => { dispatch(actions.changeInfo({})); props.history.push("/login") }}>退出登录</span>
            {getbanner.length > 0 ? 
        <Banner getbanner={getbanner}></Banner> : null}
        </div>
    )
}

